home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Very Best of Atari Inside
/
The Very Best of Atari Inside 1.iso
/
mint
/
mntlib43
/
mntlib
/
fgets.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-09-17
|
423b
|
23 lines
/* from Dale Schumacher's dLibs */
#include <stdio.h>
#include <stddef.h>
#include <assert.h>
char *fgets(data, limit, fp)
char *data;
register int limit;
register FILE *fp;
{
register char *p = data;
register int c = EOF;
assert((data != NULL));
while((--limit > 0) && ((c = getc(fp)) != EOF))
if((*p++ = c) == '\n')
break;
*p = '\0';
return((c == EOF && p == data) ? NULL : data); /* NULL == EOF */
}